package com.xauto.pioneer.appuser.activity.mine.balance;

import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.xauto.pioneer.appuser.R;
import com.xauto.pioneer.appuser.activity.BaseActivity;
import com.xauto.pioneer.appuser.interfaces.MemberCallBack;
import com.xauto.pioneer.appuser.model.Member;
import com.xauto.pioneer.appuser.util.DataLoadUtil;
import com.xauto.pioneer.appuser.view.TopBar;

import butterknife.Bind;
import butterknife.OnClick;

/***
 * 我的余额 页面
 * @author Lemon Mon 6 Mar 17:00
 */
public class BalanceActivity extends BaseActivity {

    @Bind(R.id.topBar) TopBar topBar;
    @Bind(R.id.tvAccountBalance) TextView tvAccountBalance;
    @Bind(R.id.tvDepositBalance) TextView tvDepositBalance;
    private Member member;
    @Override
    protected int getContentView() {
        return R.layout.ac_balance;
    }

    @Override
    protected void initView() {
        topBar.showView(TopBar.LEFT_IMAGE_BTN, TopBar.TITLE);
        topBar.setImage(TopBar.LEFT_IMAGE_BTN, R.mipmap.ic_common_left);
        topBar.setText(TopBar.TITLE, R.string.mine_balance);
        topBar.setLeftOnClick(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
    }

    @Override
    protected void initData() {
    }

    @Override
    protected void onStart() {
        super.onStart();
        //刷新页面
        DataLoadUtil.refreshMemberData(mContext, new MemberCallBack() {
            @Override
            public void getMember(Member m) {
                member = m;
                setView();
            }
        });
    }
    void setView(){
        tvAccountBalance.setText("¥"+member.member_account_info.balance_amount+"元");
        tvDepositBalance.setText("¥"+member.member_account_info.deposit_amount+"元");
    }

    @OnClick({R.id.llAccountBalance, R.id.llDepositBalance})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.llAccountBalance:
                //账户余额跳转
                startActivity(new Intent(mContext, AccountBalanceActivity.class));
                break;
            case R.id.llDepositBalance:
                //押金余额跳转
                startActivity(new Intent(mContext, DepositBalanceActivity.class));
                break;
        }
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
    }
}
